package helper;

import java.io.IOException;
import java.net.URL;

import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import dataFormat.FBUser;

public abstract class GetFBUserPhotoHelper extends AsyncTask<FBUser, Void, FBUser> {

	@Override
	protected FBUser doInBackground(FBUser... params) {
		try {
			URL url = new URL("https://graph.facebook.com/" + params[0].getId() + "/picture");
			
			params[0].setPhoto(BitmapFactory.decodeStream(url.openConnection().getInputStream()));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return params[0];
	}
	
	@Override
	protected abstract void onPostExecute(FBUser fbUser);
}
